<?php defined("MAIN_DIR") or die("No direct access");

$bank_id = $route->GET('bank_id');

$bank_res = mysql_query("select `bank_id`,`name` from `bank` where `bank_id` = '$bank_id' limit 1");
if (mysql_num_rows($bank_res) == 0) {
	to("/admin/mentions/");
}

$bank_row = mysql_fetch_array($bank_res);

require_once ADMIN.HEADFILE;
?>
<div align="left">
<h1>Отзывы - <?php echo $bank_row['name']; ?></h1><?php
$mentions_query = "select * from `vote` where `bank_id` = '$_GET[bank_id]' order by `vote_id`";

$limit = 10;
$mentions_result = mysql_query($mentions_query);
$count = mysql_num_rows($mentions_result);
$page = 1;
if (isset($_GET['page']))
	$page = $_GET['page'];
$max_page = ceil($count/$limit);
if ($max_page == 0)
	$max_page++;
if ($page > $max_page)
	$page = $max_page;
elseif ($page < 1)
	$page = 1;
$start_list = (ceil($page)-1)*$limit;
$mentions_query .= " limit $start_list,$limit";
$mentions_result = mysql_query($mentions_query);
$mentions_count = mysql_num_rows($mentions_result);
?>
<table cellpadding="5" cellspacing="0" class='light'>
	<tr id='header'>
		<td width="300px" style="border-bottom:1px gray solid">Текст</td>
		<td width="100px" style="border-bottom:1px gray solid">Оценка</td>
		<td width="100px" style="border-bottom:1px gray solid">IP</td>
		<td width="100px" style="border-bottom:1px gray solid">Действия</td>
	</tr><?php
	while ($mentions_row = mysql_fetch_array($mentions_result))
	{
		?><tr>
			<td><?php echo $mentions_row['text']; ?></td>
			<td><?php
				switch($mentions_row['mark'])
				{
					case -1: echo "<span style='color:red'>Отрицательный</span>"; break;
					case 0: echo "<span style='color:grey'>Нейтральный</span>"; break;
					case 1: echo "<span style='color:green'>Положительный</span>"; break;
				}
			?></td>
			<td><?php echo $mentions_row['user_ip']?></td>
			<td>
				<a onclick='return confirm_del()' href='/admin/mentions/delete/<?php echo $mentions_row['vote_id']; ?>?bank_id=<?php echo $bank_id; ?>'>Удалить</a>
			</td>
		</tr><?php
	}
?></table>
<div id="pages"><?php require_once APP."pageskin.php"; ?></div>
<br /><a href='/admin/mentions'>Назад</a><br />
</div>

<?php require_once ADMIN.FOOTERFILE; ?>